package com.xiaoyao.myframeapp.core.subscriber;

import com.xiaoyao.myframeapp.core.BaseEntity;
import com.xiaoyao.myframeapp.core.Exception.ApiException;

import io.reactivex.Observer;

/**
 * @author Administrator
 * @Author xiaoyao
 * @Email xiao80206040@qq.com
 * @Explain
 * @date 2018/7/3 0003
 */
public abstract class BaseApiObserver<T> implements Observer<BaseEntity<T>> {

    @Override
    public void onError(Throwable e) {
//        ApiException apiException = (ApiException) e;
        ApiException apiException = ApiException.handleException(e);
        onError(apiException);
    }

    /**
     * @param e 错误的一个回调
     */
    protected abstract void onError(ApiException e);

}